<script lang="ts" setup>
import { removeToken } from '../../utils/auth'
import { loginFlagStore } from '../../store'

const store = loginFlagStore()
const logout = async () => {
    const result = await removeToken()
    store.setLoginFlag(false)
    console.log(result)
    // 判断是不是打开的popup.html，如果是的话，则刷新当前被激活的tabs页
    if (!chrome.tabs) return
    chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
        const activeTab = tabs[0]
        if (activeTab && activeTab.id !== undefined) {
            chrome.tabs.reload(activeTab.id)
        }
    })
}
</script>

<template>
    <div class="home">
        <!-- Home -->
        demo_home
        <el-button type="primary" @click="logout()">退出登录</el-button>
    </div>
</template>
